package com.gaohe.web.controller.hotal;

import com.gaohe.common.annotation.Log;
import com.gaohe.common.core.controller.BaseController;
import com.gaohe.common.core.domain.AjaxResult;
import com.gaohe.common.core.page.TableDataInfo;
import com.gaohe.common.enums.BusinessType;
import com.gaohe.common.utils.poi.ExcelUtil;
import com.gaohe.hotal.domain.HotWay;
import com.gaohe.hotal.service.IHotWayService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 价格方案Controller
 *
 * @author ruoyi
 * @date 2025-07-02
 */
@RestController
@RequestMapping("/hotal/way")
public class HotWayController extends BaseController
{
    @Autowired
    private IHotWayService hotWayService;

    /**
     * 查询价格方案列表
     */
    @PreAuthorize("@ss.hasPermi('hotal:way:list')")
    @GetMapping("/list")
    public TableDataInfo list(HotWay hotWay)
    {
        startPage();
        List<HotWay> list = hotWayService.selectHotWayList(hotWay);
        return getDataTable(list);
    }

    /**
     * 导出价格方案列表
     */
    @PreAuthorize("@ss.hasPermi('hotal:way:export')")
    @Log(title = "价格方案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotWay hotWay)
    {
        List<HotWay> list = hotWayService.selectHotWayList(hotWay);
        ExcelUtil<HotWay> util = new ExcelUtil<HotWay>(HotWay.class);
        util.exportExcel(response, list, "价格方案数据");
    }

    /**
     * 获取价格方案详细信息
     */
    @PreAuthorize("@ss.hasPermi('hotal:way:query')")
    @GetMapping(value = "/{wayId}")
    public AjaxResult getInfo(@PathVariable("wayId") Long wayId)
    {
        return success(hotWayService.selectHotWayByWayId(wayId));
    }

    /**
     * 新增价格方案
     */
    @PreAuthorize("@ss.hasPermi('hotal:way:add')")
    @Log(title = "价格方案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotWay hotWay)
    {
        return toAjax(hotWayService.insertHotWay(hotWay));
    }

    /**
     * 修改价格方案
     */
    @PreAuthorize("@ss.hasPermi('hotal:way:edit')")
    @Log(title = "价格方案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotWay hotWay)
    {
        return toAjax(hotWayService.updateHotWay(hotWay));
    }

    /**
     * 删除价格方案
     */
    @PreAuthorize("@ss.hasPermi('hotal:way:remove')")
    @Log(title = "价格方案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{wayIds}")
    public AjaxResult remove(@PathVariable Long[] wayIds)
    {
        return toAjax(hotWayService.deleteHotWayByWayIds(wayIds));
    }
}
